﻿using System;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;

namespace Malu.WebTemplates
{
    public class TabberHeader : System.Web.UI.UserControl
    {
        protected HtmlTableCell tdTabber;
        protected Literal ltTitle;

        public string DivID
        {
            get
            {
                if (ViewState["DivID"] == null)
                {
                    ViewState["DivID"] = "div1";
                }
                return ViewState["DivID"].ToString();
            }
            set
            {
                ViewState["DivID"] = value;
            }
        }

        public bool Selected
        {
            get
            {
                if (ViewState["Selected"] == null)
                {
                    ViewState["Selected"] = false;
                }
                return (bool)ViewState["Selected"];
            }
            set
            {
                ViewState["Selected"] = value;
            }
        }

        public string Title
        {
            get
            {
                if (ViewState["Title"] == null)
                {
                    ViewState["Title"] = string.Empty;
                }
                return ViewState["Title"].ToString();
            }
            set
            {
                ViewState["Title"] = value;
            }
        }

        protected void Page_Load(object sender, EventArgs e)
        {
            tdTabber.Attributes.Add("onmouseover", string.Format("OverChangeTabber(this, '{0}');", this.DivID));
            if (this.Selected)
            {
                string script = string.Format("<script>OverChangeTabber(document.getElementById('{0}'), '{1}');</script>", this.tdTabber.ClientID, this.DivID);
                this.Page.ClientScript.RegisterStartupScript(this.GetType(),"SelectTabber", script);
            }
            this.ltTitle.Text = this.Title;

        }
    }
}